package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2023-11-15
 * Time: 22:19
 */
public class FindOperation implements IOperation {
    public void work(BookList bookList){
        System.out.println("查找图书!");
        System.out.println("请输入要查找的书名: ");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int currentSize = bookList.getUsedSize();
        for (int i =0;i< currentSize;i++){
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                System.out.println("存在这本书,信息如下: ");
                System.out.println(book);
                return;
            }
        }
        //代码没有return ,没有要找到的书
        System.out.println("没有要找到的书,书名为: "+name);
    }
}
